<template>
  <el-dialog
    title="更改类型"
    :visible.sync="dialogTypeVisible"
    width="500px"
    @close="closeEvent"
  >
    <el-form ref="dataForm" :model="form" size="small" label-width="80px">
      <el-form-item label="客户类型">
        <el-radio-group v-model="form.category" size="mini">
          <el-radio label="SC" border>签约客户</el-radio>
          <el-radio label="IC" border>意向客户</el-radio>
          <el-radio label="HSC" border>公海客户</el-radio>
        </el-radio-group>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="subtransSea">确 定</el-button>
      <el-button @click="dialogTypeVisible = false">取 消</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { transSea } from "@/api/crm/customer";
export default {
  name: "ChangeCategory",
  data() {
    return {
      dialogTypeVisible: false,
      form: {
        customer_ids: [],
        category: ""
      }
    };
  },
  methods: {
    open(customer_ids) {
      this.form.customer_ids = customer_ids;
      this.dialogTypeVisible = true;
    },
    closeEvent() {
      Object.assign(this.form, this.$options.data().form);
    },
    subtransSea() {
      if (this.form.category === "") {
        this.$message.warning("请选择类型");
        return;
      }
      transSea(this.form, this.form.category).then(response => {
        const { code, msg } = response;
        if (code === 200) {
          this.dialogTypeVisible = false;
          this.$emit("change");
        } else {
          this.$message.error(msg);
        }
      });
    }
  }
};
</script>

<style scoped>

</style>
